package com.sur.controller;

import com.sur.pojo.Dept;
import com.sur.pojo.Employee;
import com.sur.service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: EmployeeController
 * Description:
 */
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private EmployeeService service;
    @Autowired
    private RestTemplate template;

    @RequestMapping("/getAll")
    public List getAll(){
        List<Employee> list = service.list();
        for (Employee e: list ) {
            Integer deptNo = e.getDeptNo();
            System.out.println(deptNo);
        }
        List forObject = this.template.getForObject("http://localhost:8082/dept/", List.class);
        ArrayList<Object> arrayList = new ArrayList<>();
        arrayList.add( service.list());
        arrayList.add(forObject);
        return arrayList;
    }
}

